<template>
  <div class="table-com">
    <div class="title-table">
      <span>武汉：</span>
      <span>一个什么的取悦</span>
    </div>
    <el-table
      :data="tableData"
      max-height="420"
      style="width: 100%">
      <el-table-column prop="name" label="城市名"  align="center">
        <template slot-scope="scope">
         <span style="font-weight: 600"> {{scope.row.name}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="val1" label="成交量" sortable align="center"></el-table-column>
      <el-table-column prop="price" label="价格"  sortable align="center">
        <template slot-scope="scope">
          <span style="font-weight: 600">{{scope.row.price}}</span>元
        </template>
      </el-table-column>
      <el-table-column prop="val2" label="涨跌幅"  sortable align="center">
        <template slot-scope="scope">
          <span style="color: red" v-show="scope.row.val2>0">{{scope.row.val2}}%</span>
          <span style="color: #666" v-show="scope.row.val2===0">{{scope.row.val2}}%</span>
          <span style="color: #42b983" v-show="scope.row.val2<0">{{scope.row.val2}}%</span>
        </template>
      </el-table-column>

    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: []
    }
  },
  mounted() {
    this.tableData = this.init()
  },
  methods: {
    init() {
      let list = []
      for(let i = 0;i<20;i++) {
        const obj = {name:`广州${i}`,val1: 20,price:12345 + i,val2: 0.36}
        list.push(obj)
      }
      for(let i = 0;i<30;i++) {
        const obj = {name:`上海${i}`,val1: 20,price:12345,val2: -0.16}
        list.push(obj)
      }
      return list
    }
  }
}

</script>

<style lang="scss" scoped>
.table-com{
  width: 340px;
  height: 420px;
  overflow: auto;
  border-radius: 8px;
  background-color: #ffffff;
  .title-table{
    font-weight: 600;
    padding: 12px 0 12px 10px;
  }

}
.table-com::-webkit-scrollbar{
  width: 0;
  background-color: #fff;
}
.table-com::-webkit-scrollbar-thumb{
  width: 0;
  background-color: #f0f0f0;
}
</style>
<style scoped>
/deep/ .el-table--enable-row-transition .el-table__body td{
  padding: 3px 0;
}
/deep/ .el-table--scrollable-y .el-table__body-wrapper::-webkit-scrollbar{
  width: 3px;
  background-color: #fff;
}
/deep/  .el-table--scrollable-y .el-table__body-wrapper::-webkit-scrollbar-thumb{
  width: 3px;
  background-color: #f0f0f0;
}
/deep/ .el-table th {
  padding: 0 0;
}

/deep/ .el-table .cell{
  padding: 0 0;
}

</style>
